package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main0601() {
	fp, err := os.Open("./a.txt")
	if err != nil {
		fmt.Println("打开文件失败", err)
		return
	}
	defer fp.Close()
	buf := make([]byte, 1024)
	//n,_ := fp.Read(buf)
	//fmt.Println(string(buf[:n]))
	for {
		n, err := fp.Read(buf)
		if err == io.EOF {
			break
		}
		fmt.Println(string(buf[:n]))
	}
}

func main() {
	fp, err := os.OpenFile("./a.txt", os.O_RDONLY, 6)
	if err != nil{
		fmt.Println("文件打开失败")
		return
	}
	defer fp.Close()
	r := bufio.NewReader(fp)
	//slice,_ := r.ReadBytes('\n')
	//fmt.Println(string(slice))
	//slice,_ = r.ReadBytes('\n')
	//fmt.Print(string(slice))
	for {
		slice,err := r.ReadBytes('h')
		fmt.Println(string(slice))
		if err == io.EOF {
			break
		}
	}
}
